﻿<%@ Page Language="C#"  MasterPageFile="~/MasterPages/MasterPage.master" AutoEventWireup="true"  CodeFile="UnitTableEdit.aspx.cs" Inherits="UnitTableEdit" Title="UnitTable Edit" %>

<asp:Content ID="Content2" ContentPlaceHolderID="TitleContent" Runat="Server">Unit Table - Add/Edit</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentContent" Runat="Server">
		<data:MultiFormView ID="FormView1" DataKeyNames="UnitCode" runat="server" DataSourceID="UnitTableDataSource">
		
			<EditItemTemplatePaths>
				<data:TemplatePath Path="~/Admin/UserControls/UnitTableFields.ascx" />
			</EditItemTemplatePaths>
		
			<InsertItemTemplatePaths>
				<data:TemplatePath Path="~/Admin/UserControls/UnitTableFields.ascx" />
			</InsertItemTemplatePaths>
		
			<EmptyDataTemplate>
				<b>UnitTable not found!</b>
			</EmptyDataTemplate>
			
			<FooterTemplate>
				<asp:Button ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert" Text="Insert" />
				<asp:Button ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" Text="Update" />
				<asp:Button ID="CancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" />
			</FooterTemplate>

		</data:MultiFormView>
		
		<data:UnitTableDataSource ID="UnitTableDataSource" runat="server"
			SelectMethod="GetByUnitCode"
		>
			<Parameters>
				<asp:QueryStringParameter Name="UnitCode" QueryStringField="UnitCode" Type="String" />

			</Parameters>
		</data:UnitTableDataSource>
		
		<br />

		<data:EntityGridView ID="GridViewAfiDetail1" runat="server"
			AutoGenerateColumns="False"	
			OnSelectedIndexChanged="GridViewAfiDetail1_SelectedIndexChanged"			 			 
			DataSourceID="AfiDetailDataSource1"
			DataKeyNames="LineItem"
			AllowMultiColumnSorting="false"
			DefaultSortColumnName="" 
			DefaultSortDirection="Ascending"	
			ExcelExportFileName="Export_AfiDetail.xls"  		
			Visible='<%# (FormView1.DefaultMode == FormViewMode.Insert) ? false : true %>'	
			>
			<Columns>
				<asp:CommandField ShowSelectButton="True" />
				<data:HyperLinkField HeaderText="Afi Code" DataNavigateUrlFormatString="AfiEdit.aspx?AfiCode={0}" DataNavigateUrlFields="AfiCode" DataContainer="AfiCodeSource" DataTextField="ClientName" />
				<data:HyperLinkField HeaderText="Product Code" DataNavigateUrlFormatString="ProductEdit.aspx?ProductCode={0}" DataNavigateUrlFields="ProductCode" DataContainer="ProductCodeSource" DataTextField="ProductDescription" />
				<data:HyperLinkField HeaderText="Unit" DataNavigateUrlFormatString="UnitTableEdit.aspx?UnitCode={0}" DataNavigateUrlFields="UnitCode" DataContainer="UnitSource" DataTextField="UnitDescrption" />
				<asp:BoundField DataField="Quantity" HeaderText="Quantity" SortExpression="[Quantity]" />				
				<asp:BoundField DataField="UnitCost" HeaderText="Unit Cost" SortExpression="[UnitCost]" />				
				<asp:BoundField DataField="CoverPeriodFrom" HeaderText="Cover Period From" SortExpression="[CoverPeriodFrom]" />				
				<asp:BoundField DataField="CoverPeriodTo" HeaderText="Cover Period To" SortExpression="[CoverPeriodTo]" />				
			</Columns>
			<EmptyDataTemplate>
				<b>No Afi Detail Found! </b>
				<asp:HyperLink runat="server" ID="hypAfiDetail" NavigateUrl="~/admin/AfiDetailEdit.aspx">Add New</asp:HyperLink>
			</EmptyDataTemplate>
		</data:EntityGridView>					
		
		<data:AfiDetailDataSource ID="AfiDetailDataSource1" runat="server" SelectMethod="Find"
			EnableDeepLoad="True"
			>
			<DeepLoadProperties Method="IncludeChildren" Recursive="False">
	            <Types>
					<data:AfiDetailProperty Name="Afi"/> 
					<data:AfiDetailProperty Name="Product"/> 
					<data:AfiDetailProperty Name="UnitTable"/> 
				</Types>
			</DeepLoadProperties>
			
		    <Parameters>
				<data:SqlParameter Name="Parameters">
					<Filters>
						<data:AfiDetailFilter  Column="Unit" QueryStringField="UnitCode" /> 
					</Filters>
				</data:SqlParameter>
				<data:CustomParameter Name="OrderByClause" Value="" ConvertEmptyStringToNull="false" /> 
		    </Parameters>
		</data:AfiDetailDataSource>		
		
		<br />
		

</asp:Content>

